package com.mmsj;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button  button = findViewById(R.id.button);
        button.setOnClickListener(v -> {
            Toast toast = Toast.makeText(MainActivity.this, "您有一个新的订单,请您接收.", Toast.LENGTH_SHORT);
            toast.show();
        });

        Button  button2 = findViewById(R.id.button2);
        button2.setOnClickListener(v -> {
            // 创建构造器
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setTitle("重要提示");
            builder.setMessage("检测到您未安装原神 是否一键为您安装");
            builder.setPositiveButton("确定", (dialog, which) -> {
                Toast toast = Toast.makeText(MainActivity.this, "已为您安装原神", Toast.LENGTH_SHORT);
                toast.show();
            });
            builder.setNegativeButton("十分确定", (dialog, which) -> {
                Toast toast = Toast.makeText(MainActivity.this, "已为您安装原神", Toast.LENGTH_SHORT);
                toast.show();
            });
            builder.show();
        });

        Button  button3 = findViewById(R.id.button3);
        button3.setOnClickListener(v -> {
            // 创建构造器
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setTitle("列表选择");
            String [] items = {"选项1", "选项2", "选项3"};
            // 设置列表
            builder.setItems(items, (dialog, which) -> {
                Toast toast = Toast.makeText(MainActivity.this, "您选择了" + items[which], Toast.LENGTH_SHORT);
                toast.show();
            });
            builder.show();
        });

        Button button4 = findViewById(R.id.button4);
        button4.setOnClickListener(v -> {
            // 创建进度对话框
            ProgressDialog dialog = new ProgressDialog(MainActivity.this);
            dialog.setTitle("温馨提示");
            dialog.setMessage("请稍候...");
        });

    }
}